﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;

namespace System.Management.HyperV.MsBuildTasks
{
    public class CreateSnapshot : Task
    {
        [Required]
        public string VirtualMachineName
        {
            get;
            set;
        }

        public override bool Execute()
        {
            try
            {
                string[] vmNames = VirtualMachineName.Split(';');
                foreach (string vmName in vmNames)
                {
                    using (var vsms = new VirtualSystemManagementService())
                    {
                        var snap = vsms.CreateVirtualSystemSnapshot(vmName);
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
